home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / telecomm / misc / linkz88.lha / LinkZ88 / Source / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-13  |  5.9 KB  |  210 lines

  1. /*********************************************/
  2. /*                                           */
  3. /*       Designer (C) Ian OConnor 1994       */
  4. /*                                           */
  5. /*      Designer Produced C include file     */
  6. /*                                           */
  7. /*********************************************/
  8.  
  9. #include <exec/types.h>
  10. #include <exec/memory.h>
  11. #include <dos/dosextens.h>
  12. #include <intuition/screens.h>
  13. #include <intuition/intuition.h>
  14. #include <intuition/gadgetclass.h>
  15. #include <libraries/gadtools.h>
  16. #include <diskfont/diskfont.h>
  17. #include <utility/utility.h>
  18. #include <graphics/gfxbase.h>
  19. #include <workbench/workbench.h>
  20. #include <graphics/scale.h>
  21. #include <clib/exec_protos.h>
  22. #include <clib/wb_protos.h>
  23. #include <clib/intuition_protos.h>
  24. #include <clib/gadtools_protos.h>
  25. #include <clib/graphics_protos.h>
  26. #include <clib/utility_protos.h>
  27. #include <string.h>
  28. #include <clib/diskfont_protos.h>
  29.  
  30. #include "windows.h"
  31.  
  32.  
  33. struct Window *mainwin = NULL;
  34. APTR mainwinVisualInfo;
  35. APTR mainwinDrawInfo;
  36. struct Gadget *mainwinGList;
  37. struct Gadget *mainwinGadgets[9];
  38. UBYTE mainwinFirstRun = 0;
  39.  
  40. ULONG mainwinGadgetTags[] =
  41.     {
  42.     (GTLV_Selected), 0,
  43.     (TAG_END),
  44.     (GA_Disabled), TRUE,
  45.     (TAG_END),
  46.     (GA_Disabled), TRUE,
  47.     (TAG_END),
  48.     (GA_Disabled), TRUE,
  49.     (TAG_END),
  50.     (GA_Disabled), TRUE,
  51.     (TAG_END),
  52.     (GA_Disabled), TRUE,
  53.     (TAG_END),
  54.     (GTTX_Border), TRUE,
  55.     (TAG_END),
  56.     };
  57.  
  58. UWORD mainwinGadgetTypes[] =
  59.     {
  60.     LISTVIEW_KIND,
  61.     BUTTON_KIND,
  62.     BUTTON_KIND,
  63.     BUTTON_KIND,
  64.     BUTTON_KIND,
  65.     BUTTON_KIND,
  66.     BUTTON_KIND,
  67.     TEXT_KIND,
  68.     BUTTON_KIND,
  69.     };
  70.  
  71. struct NewGadget mainwinNewGadgets[] =
  72.     {
  73.     2, 2, 230, 100, NULL, NULL, mainwin_listview, 1, NULL,  (APTR)&mainwinGadgetTags[0],
  74.     235, 72, 120, 14, (UBYTE *)"Get binary...", NULL, mainwin_getbinary, 16, NULL,  (APTR)&mainwinGadgetTags[3],
  75.     235, 88, 120, 14, (UBYTE *)"Put binary...", NULL, mainwin_putbinary, 16, NULL,  (APTR)&mainwinGadgetTags[6],
  76.     2, 104, 70, 14, (UBYTE *)"All", NULL, mainwin_all, 16, NULL,  (APTR)&mainwinGadgetTags[9],
  77.     82, 104, 70, 14, (UBYTE *)"None", NULL, mainwin_none, 16, NULL,  (APTR)&mainwinGadgetTags[12],
  78.     162, 104, 70, 14, (UBYTE *)"Parent", NULL, mainwin_parent, 16, NULL,  (APTR)&mainwinGadgetTags[15],
  79.     235, 2, 120, 14, (UBYTE *)"About...", NULL, mainwin_about, 16, NULL,  NULL,
  80.     2, 120, 353, 14, NULL, NULL, mainwin_status, 1, NULL,  (APTR)&mainwinGadgetTags[18],
  81.     235, 104, 120, 14, (UBYTE *)"Devices", NULL, mainwin_devices, 16, NULL,  NULL,
  82.     };
  83.  
  84. void RendWindowmainwin( struct Window *Win, void *vi )
  85. {
  86. UWORD offx = Win->BorderLeft;
  87. UWORD offy = Win->BorderTop;
  88. ULONG scalex = 65535*Win->WScreen->RastPort.Font->tf_XSize/8;
  89. ULONG scaley = 65535*Win->WScreen->RastPort.Font->tf_YSize/8;
  90. if (Win != NULL) 
  91.     {
  92.     }
  93. }
  94.  
  95. int OpenWindowmainwin( void )
  96. {
  97. struct Screen *Scr;
  98. UWORD offx, offy;
  99. UWORD loop;
  100. struct NewGadget newgad;
  101. struct Gadget *Gad;
  102. struct Gadget *Gad2;
  103. APTR Cla;
  104. ULONG scalex,scaley;
  105. if (mainwinFirstRun == 0)
  106.     {
  107.     mainwinFirstRun = 1;
  108.     }
  109. if (mainwin == NULL)
  110.     {
  111.     Scr = LockPubScreen(NULL);
  112.     if (NULL != Scr)
  113.         {
  114.         offx = Scr->WBorLeft;
  115.         offy = Scr->WBorTop + Scr->Font->ta_YSize+1;
  116.         scalex = 65535*Scr->RastPort.Font->tf_XSize/8;
  117.         scaley = 65535*Scr->RastPort.Font->tf_YSize/8;
  118.         if (NULL != ( mainwinVisualInfo = GetVisualInfoA( Scr, NULL)))
  119.             {
  120.             if (NULL != ( mainwinDrawInfo = GetScreenDrawInfo( Scr)))
  121.                 {
  122.                 mainwinGList = NULL;
  123.                 Gad = CreateContext( &mainwinGList);
  124.                 for ( loop=0 ; loop<9 ; loop++ )
  125.                     if (mainwinGadgetTypes[loop] != 198)
  126.                         {
  127.                         CopyMem((char * )&mainwinNewGadgets[loop], ( char * )&newgad, (long)sizeof( struct NewGadget ));
  128.                         newgad.ng_VisualInfo = mainwinVisualInfo;
  129.                         newgad.ng_LeftEdge = newgad.ng_LeftEdge*scalex/65535;
  130.                         newgad.ng_TopEdge = newgad.ng_TopEdge*scaley/65535;
  131.                         if (mainwinGadgetTypes[loop] != GENERIC_KIND)
  132.                             {
  133.                             newgad.ng_Width = newgad.ng_Width*scalex/65535;
  134.                             newgad.ng_Height = newgad.ng_Height*scaley/65535;
  135.                             };
  136.                         newgad.ng_TextAttr = Scr->Font;
  137.                         newgad.ng_LeftEdge += offx;
  138.                         newgad.ng_TopEdge += offy;
  139.                         mainwinGadgets[ loop ] = NULL;
  140.                         mainwinGadgets[ newgad.ng_GadgetID - mainwinFirstID ] = Gad = CreateGadgetA( mainwinGadgetTypes[loop], Gad, &newgad, newgad.ng_UserData );
  141.                         }
  142.                 for ( loop=0 ; loop<9 ; loop++ )
  143.                     if (mainwinGadgetTypes[loop] == 198)
  144.                         {
  145.                         mainwinGadgets[ loop ] = NULL;
  146.                         Cla = NULL;
  147.                         if (Gad)
  148.                             mainwinGadgets[ loop ] = Gad2 = (struct Gadget *) NewObjectA( (struct IClass *)Cla, mainwinNewGadgets[ loop ].ng_GadgetText, mainwinNewGadgets[ loop ].ng_UserData );
  149.                         }
  150.                 if (Gad != NULL)
  151.                     {
  152.                     if (NULL != (mainwin = OpenWindowTags( NULL, (WA_Left), 136,
  153.                                     (WA_Top), 37,
  154.                                     (WA_Width), 362*scalex/65535+offx,
  155.                                     (WA_Height), 137*scaley/65535+offy,
  156.                                     (WA_Title), "LinkZ88 ©1995 Andy Dean",
  157.                                     (WA_ScreenTitle), "LinkZ88 ©1995 Andy Dean",
  158.                                     (WA_MinWidth), 150,
  159.                                     (WA_MinHeight), 25,
  160.                                     (WA_MaxWidth), 1200,
  161.                                     (WA_MaxHeight), 1200,
  162.                                     (WA_DragBar), TRUE,
  163.                                     (WA_DepthGadget), TRUE,
  164.                                     (WA_CloseGadget), TRUE,
  165.                                     (WA_Activate), TRUE,
  166.                                     (WA_Dummy+0x30), TRUE,
  167.                                     (WA_SmartRefresh), TRUE,
  168.                                     (WA_AutoAdjust), TRUE,
  169.                                     (WA_Gadgets), mainwinGList,
  170.                                     (WA_IDCMP),4194940,
  171.                                     (TAG_END))))
  172.                         {
  173.                         RendWindowmainwin(mainwin, mainwinVisualInfo );
  174.                         GT_RefreshWindow( mainwin, NULL);
  175.                         RefreshGList( mainwinGList, mainwin, NULL, ~0);
  176.                         UnlockPubScreen( NULL, Scr);
  177.                         return( 0L );
  178.                         }
  179.                     }
  180.                 FreeGadgets( mainwinGList);
  181.                 FreeScreenDrawInfo( Scr, mainwinDrawInfo );
  182.                 }
  183.             FreeVisualInfo( mainwinVisualInfo );
  184.             }
  185.         UnlockPubScreen( NULL, Scr);
  186.         }
  187.     }
  188. else
  189.     {
  190.     WindowToFront(mainwin);
  191.     ActivateWindow(mainwin);
  192.     return( 0L );
  193.     }
  194. return( 1L );
  195. }
  196.  
  197. void CloseWindowmainwin( void )
  198. {
  199. if (mainwin != NULL)
  200.     {
  201.     FreeScreenDrawInfo( mainwin->WScreen, mainwinDrawInfo );
  202.     mainwinDrawInfo = NULL;
  203.     CloseWindow( mainwin);
  204.     mainwin = NULL;
  205.     FreeVisualInfo( mainwinVisualInfo);
  206.     FreeGadgets( mainwinGList);
  207.     }
  208. }
  209.  
  210.